#pragma once

struct GLFramebuffer
{
	const std::string		name;
	uint			handle;
	uint			width;
	uint			height;
	std::vector<GLenum>		attachments;
	std::vector<GLTexture*> attachmentsPtn;
	GLTexture*				depthAttachment;
	bool					validated;

	GLFramebuffer(const std::string& name) :
		handle(0),
		name(name),
		validated(false),
		depthAttachment(NULL),
		width(0),
		height(0)
	{}
};

struct GLTexture;

class FramebufferWrapper
{
protected:
	FramebufferWrapper();
	~FramebufferWrapper();

	static GLFramebuffer*	_boundFramebuffer;
	static int				_framebuffersCount;
	static std::map<std::string, GLFramebuffer*> _framebuffersMap;

public:
	static GLFramebuffer*	GenFramebuffer(const std::string& name);
	static void				DeleteFramebuffer(GLFramebuffer** fb);

	static void				SetFramebufferColorAttachment(GLFramebuffer* fb, int mountingPoint, GLTexture* t);
	static void				SetFramebufferDepthAttachment(GLFramebuffer* fb, GLTexture* t);
	static void				ValidateFramebuffer(GLFramebuffer* fbo);

	static void				BindFramebuffer(GLFramebuffer* fbo, bool force = false);
	static void				UnbindFramebuffer();
};

